import { BasicColumn } from '@/components/Table';
import { useRender } from '@/hooks/component/useRender';
import { FormSchema } from '@/components/Form';
import { DictEnum } from '@/enums/dictEnum';
import { getDictOptions } from '@/utils/dict';
import { shopInfoList } from '@/api/shop/manage/index';

const { renderDict } = useRender();
export const formSchems: FormSchema[] = [
  {
    label: '店铺名称',
    field: 'shopId',
    component: 'ApiSelect',
    componentProps: {
      api: shopInfoList,
      showSearch: true,
      optionFilterProp: 'label',
      labelField: 'shopName',
      valueField: 'shopId',
    },
  },
  {
    label: '商品标识',
    field: 'linkProductId',
    component: 'Input',
  },
  {
    label: '商品名称',
    field: 'productName',
    component: 'Input',
  },
  {
    label: 'OTA平台关联标识',
    field: 'linkOtherId',
    component: 'Input',
  },
  {
    label: 'OTA渠道类型',
    field: 'linkOtherType',
    component: 'Select',
    componentProps: {
      options: getDictOptions(DictEnum.OAT_CHANNEL_TYPE),
    },
  },
  {
    label: '商品类型',
    field: 'linkProductType',
    component: 'Select',
    componentProps: {
      options: getDictOptions(DictEnum.CATE_TYPE_LIST),
    },
  },
];

export const columns: BasicColumn[] = [
  {
    title: '店铺名称',
    dataIndex: 'shopName',
  },
  {
    title: '商品关联标识',
    dataIndex: 'linkProductId',
  },
  {
    title: 'OTA平台关联标识',
    dataIndex: 'linkOtherId',
  },
  {
    title: '验证方式',
    dataIndex: 'verifyType',
    customRender({ value }) {
      return renderDict(value, DictEnum.VERIFY_TYPE);
    },
  },
  {
    title: 'OTA渠道类型',
    dataIndex: 'linkOtherType',
    customRender({ value }) {
      return renderDict(value, DictEnum.OAT_CHANNEL_TYPE);
    },
  },
  {
    title: '商品类型',
    dataIndex: 'linkProductType',
    customRender({ value }) {
      return renderDict(value, DictEnum.CATE_TYPE_LIST);
    },
  },
  {
    title: '商品名称',
    dataIndex: 'productName',
  },
];

export const modalSchemas: FormSchema[] = [
  {
    label: '',
    field: 'id',
    required: false,
    component: 'Input',
    show: false,
  },
  {
    label: '店铺名称',
    field: 'shopId',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      api: shopInfoList,
      showSearch: true,
      optionFilterProp: 'label',
      labelField: 'shopName',
      valueField: 'shopId',
    },
  },
  {
    label: '商品标识',
    field: 'linkProductId',
    required: true,
    component: 'Input',
  },
  {
    label: '商品名称',
    field: 'productName',
    required: true,
    component: 'Input',
  },
  {
    label: 'OTA关联标识',
    field: 'linkOtherId',
    required: true,
    component: 'Input',
  },
  {
    label: '关联类型',
    field: 'linkType',
    required: false,
    component: 'Input',
    show: false,
  },
  {
    label: '关联商品类型',
    field: 'linkProductType',
    required: false,
    component: 'Input',
    show: false,
  },
  {
    label: '验证方式',
    field: 'verifyType',
    required: true,
    component: 'Select',
    componentProps: {
      options: getDictOptions(DictEnum.VERIFY_TYPE),
    },
  },
  {
    label: 'OTA渠道类型',
    field: 'linkOtherType',
    required: true,
    component: 'Select',
    componentProps: {
      options: getDictOptions(DictEnum.OAT_CHANNEL_TYPE),
    },
  },
];
